include(GenerateExportHeader)

##设置target名称
set(TARGET_NAME MeshBoolean)

##设置源代码目录
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
# Find includes in corresponding build directories 
set(CMAKE_INCLUDE_CURRENT_DIR ON) 
# Instruct CMake to run moc automatically when needed. 
set(CMAKE_LIBRARY_PATH "C:\\Program Files (x86)\\Microsoft SDKs\\Windows\\v7.0A\\Lib") 
#set(CMAKE_AUTOMOC ON)

# 提取所有的源文件(头文件和源文件分开提取)
file(GLOB_RECURSE  HEADER_FILES
    LIST_DIRECTORIES False  CONFIGURE_DEPENDS
    "${SOURCE_DIR}/*.h*"
)
file(GLOB_RECURSE  SRC_FILES
    LIST_DIRECTORIES False  CONFIGURE_DEPENDS
    "${SOURCE_DIR}/*.c*"
    "${SOURCE_DIR}/*.ui"
)

# 为VS设置源代码文件夹
source_group(
    TREE "${SOURCE_DIR}"
    PREFIX "Header Files"
    FILES ${HEADER_FILES}
)
source_group(
    TREE "${SOURCE_DIR}"
    PREFIX "Source Files"
    FILES ${SRC_FILES}
)

# 添加target及别名
add_library(${TARGET_NAME} SHARED)

# 创建动态库的符号导出头文件
generate_export_header(${TARGET_NAME}
    BASE_NAME "${TARGET_NAME}"
    EXPORT_FILE_NAME "${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_NAME}.h"
)

# 指定源文件
target_sources(${TARGET_NAME}
    PRIVATE  ${SRC_FILES}
    PRIVATE  ${HEADER_FILES}
    PRIVATE  ${QRC_FILES}
)

# 设置预处理器定义
if(MSVC)
    target_compile_definitions(${TARGET_NAME}
        PRIVATE UNICODE NOMINMAX
    )
endif()

# 配置构建/使用时的头文件路径
target_include_directories(${TARGET_NAME}
    PUBLIC $<BUILD_INTERFACE:${SOURCE_DIR}>
)

##设置所在文件夹
set_target_properties(${TARGET_NAME} PROPERTIES
    FOLDER "示例程序"
)

##设置库依赖
target_link_libraries(${TARGET_NAME}
    PRIVATE Gcmp::All UIPlatform
)
